/*
  Author: Ionel Crisu - crisuionel@yahoo.com
  support@FlashExtended.com
*/
package com.flashextended.utils.graphics.buttons
{
	import flash.display.Bitmap;
	import flash.events.MouseEvent;
	import flash.filters.DropShadowFilter;
	
	import mx.core.UIComponent;	

	public class VistaButton extends UIComponent
	{
		private var imageBMP:Bitmap;
		
		public function VistaButton(bmp:Bitmap, tooltip:String="")
		{
			super();
			this.toolTip = tooltip;
			this.imageBMP = bmp;
			this.addChild(imageBMP);
			this.width = imageBMP.width;
			this.height = imageBMP.height;
			this.buttonMode = true;
			this.addEventListener(MouseEvent.MOUSE_OVER, buttonMouseOver);
			this.addEventListener(MouseEvent.MOUSE_OUT, buttonMouseOut);			
		}
		
		protected function buttonMouseOver(e:MouseEvent):void
		{
			imageBMP.y = -2;
			applayShadow();
		}
		protected function buttonMouseOut(e:MouseEvent):void
		{
			imageBMP.y = 0;
			applayShadow(false);
		}
		
		protected function applayShadow(val:Boolean=true):void
		{
			if(val)
			{
				var sh:DropShadowFilter = new DropShadowFilter(6, 45, 0, .5);
				this.filters = [sh];
			}else
			{
				this.filters = null;
			}
		}		
		
	}
}